package com.digitalchina.lxnsy.activity.mainConsult;

import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.MainCosultVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：白彦东
 * 创建时间：2016/12/28 18:10
 * 修改备注：2017/3/26 14:00:38 郑皓修改
 * ================================================
 */

public class ConsultHolder extends BaseViewHolder<MainCosultVO> {

    private SimpleDraweeView sdv;//头像
    private TextView tvExpertName;//姓名
    private TextView tvExpertTitle;//职称
    private TextView tvStatus;//状态

    private TextView tvFree;  // 是否收费
    private TextView tvTime; // 时间
    private TextView tvMsg; // 最后消息


    public ConsultHolder(ViewGroup parent) {
        super(parent, R.layout.item_consult_main);
        sdv = $(R.id.sdv_head);
        tvExpertName = $(R.id.tv_name);
        tvExpertTitle = $(R.id.tv_titles);
        tvStatus = $(R.id.tv_status);

        tvFree = $(R.id.tv_free);
        tvTime = $(R.id.tv_time);
        tvMsg = $(R.id.tv_msg);


    }

    @Override
    public void setData(final MainCosultVO data) {
        super.setData(data);

        //会话是否收费发起 0-免费 1-收费
        if("0".equals(data.getIsFee())){
            tvFree.setText("免费");
        }else{
            tvFree.setText("付费");
        }


        FrescoUtil.showImageSmall(data.getHeadImg(), sdv);

        tvExpertName.setText(data.getName());

        tvExpertTitle.setText(data.getTitle());

        tvTime.setText(data.getSessionStartTime());


        if(data.getFirstConsultContent()!=null&&data.getFirstConsultContent().contains("：")){
            String str1 = data.getFirstConsultContent().substring(0, data.getFirstConsultContent().indexOf("："));
            String content = data.getFirstConsultContent().substring(str1.length() + 1);
            tvMsg.setText(content);
        }else{
            tvMsg.setText("暂未发起咨询");
        }


        //会话状态 0-未提问 1-专家已回复 2-待回复 3-待评价 4-已评价 5-已失效
        switch (data.getSessionStatus()){
            case "0":
                tvStatus.setText("未提问");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_app_color_width_1dp_radius_18dp));
                break;
            case "1":
                tvStatus.setText("已回复");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.colorFontRed));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_red_width_1dp_radius_18dp));
                break;
            case "2":
                tvStatus.setText("待回复");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_app_color_width_1dp_radius_18dp));
                break;
            case "3":
                tvStatus.setText("待评价");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_app_color_width_1dp_radius_18dp));
                break;
            case "4":
                tvStatus.setText("已评价");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_app_color_width_1dp_radius_18dp));
                break;
            case "5":
                tvStatus.setText("已失效");
                tvStatus.setTextColor(getContext().getResources().getColor(R.color.app_color));
                tvStatus.setBackground(getContext().getResources().getDrawable(R.drawable.shape_app_color_width_1dp_radius_18dp));
                break;
        }

    }
}
